package androidvn.xenforo.fourums;

import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import androidvn.xenforo.fourums.R;

public class ConnectionFragment extends Fragment {
	Button btnRefresh;
	TextView tvMessage;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.connection_layout, container,
				false);
		tvMessage = (TextView) view.findViewById(R.id.tvMessage);
		Bundle bundle = this.getArguments();
		int errorState = bundle.getInt("error");
		if (errorState == 1) {
			tvMessage.setText(R.string.internet_connection);
		} else if (errorState == 2) {
			tvMessage.setText(R.string.server_connection);
		}

		btnRefresh = (Button) view.findViewById(R.id.btnRefresh);
		btnRefresh.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent i = new Intent(getActivity(), MainActivity.class);
				startActivity(i);
			}
		});
		return view;
	}
}
